var mongoose=require('mongoose')
    mongoose.connect('mongodb://localhost/student')
mongoose.connection.on('connected',function(){
    console.log('mongodb数据库链接成功，端口号为27017')
})
mongoose.connection.on('error',function(err){
    if(err){
        console.log("数据库链接异常，或是断开链接")
    }
})
mongoose.connection.on('disconnected',function(){
    console.log('Mongoose connection disconnected')
})
var Schema=mongoose.Schema
var studentSchema=new Schema({
name:{
    type:String,
    required:true
},
 gender:{
     type: Number,
     enum:[0,1],
     default:1
 },
   age:{
    type:Number,

   },
   height:{
    type:Number,
   },
    hobbies:{
    type:String
    },
    time:{
    type:Date,
    default: Date.now
    }
})

//到处当前数据库
module.exports=mongoose.model('Student',studentSchema)


